import { resolve } from 'node:path'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { visualizer } from 'rollup-plugin-visualizer'
import { webUpdateNotice } from '@plugin-web-update-notification/vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

export default [
  vue(),
  vueJsx(),
  AutoImport({
    resolvers: [ElementPlusResolver()],
    imports: ['vue', 'vue-router'],
  }),
  Components({
    resolvers: [ElementPlusResolver()],
  }),
  createSvgIconsPlugin({
    // eslint-disable-next-line no-undef
    iconDirs: [resolve(process.cwd(), 'src/assets/svg')],
    symbolId: 'svg-icon-[dir]-[name]',
  }),
  // createHtmlPlugin({
  //   minify: true,
  //   inject: {
  //     data: {
  //       // Vue: '<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.4.21/vue.global.js"></script>',
  //       wangEditor:
  //         '<script src="https://cdn.bootcdn.net/ajax/libs/wangeditor5/5.1.23/index.min.js"></script>',
  //       // ElementPlusIconsVue:
  //       //   '<script src="https://unpkg.com/@element-plus/icons-vue@2.3.1/dist/index.iife.min.js"></script>',
  //     },
  //   },
  // }),
  visualizer({
    open: true,
    gzipSize: true,
    brotliSize: true,
  }),
  webUpdateNotice({
    logVersion: true,
    hiddenDismissButton: true,
    notificationProps: {
      title: '系统更新提示',
      description: '检测到系统有新版本',
      buttonText: '刷新',
    },
  }),
]
